<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover" />
    <title>月度意见分值设置</title>
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/weui.min.css')}}">
    <link rel="stylesheet" href="{{asset('/addons/jquery-weui-build/css/jquery-weui.css')}}">
    <link rel="stylesheet" href="{{asset('/css/system/iconfont.css')}}">
    <link rel="stylesheet" href="/css/admin/mobileSelect.css">
    <link rel="stylesheet" href="/css/admin/newadd.css">
   {{-- <link rel="stylesheet" href="{{asset('/css/system/common.css')}}">--}}
    @if($skinid == 3)
        <link rel="stylesheet" href="/css/system/common.css?v=2019052401">
        <link rel="stylesheet" href="/css/system/rewards-setting.css?v=20181214021">
        <link rel="stylesheet" href="/css/admin/add-tips.css?v={{time()}}">
    @elseif($skinid == 1)
        <link rel="stylesheet" href="/css/theme-blue/system/common.css?v={{time()}}">
        <link rel="stylesheet" href="/css/theme-blue/system/rewards-setting.css">
        <link rel="stylesheet" href="/css/theme-blue/admin/add-tips.css?v={{time()}}">
    @elseif($skinid == 2)
        <link rel="stylesheet" href="/css/theme-pink/system/iconfont-pink.css">
        <link rel="stylesheet" href="/css/theme-pink/system/common.css?v=2019052401">
        <link rel="stylesheet" href="/css/system/rewards-setting.css?v=20181214021">
        <link rel="stylesheet" href="/css/theme-pink/admin/add-tips.css?v={{time()}}">
    @endif
    <style>
        #trigger-select-year {
            cursor: pointer;
            text-align: right;
            margin-right: 10px;
            color:#535353;
        }
        .weui-cell__bd.select-year:after{
            content: " ";
            display: inline-block;
            height: 6px;
            width: 6px;
            border-width: 2px 2px 0 0;
            border-color: #c8c8cd;
            border-style: solid;
            -webkit-transform: matrix(.71,.71,-.71,.71,0,0);
            transform: matrix(.71,.71,-.71,.71,0,0);
            position: relative;
            top: -2px;
            position: absolute;
            top: 50%;
            margin-top: -4px;
            right: 12px;
        }
    </style>
    @include('sysadmin.head')
</head>
<style>

</style>
<body ontouchstart>
<div class="mian-container">
    <div class="weui-cell" style="height:30px;">
        <div class="weui-cell__hd">
            <p><i class="icon iconfont icon-kaoqin year-param-icon" style="font-size: 24px;"></i><span style="vertical-align: middle; margin-left: 10px; color:#535353;">选择时间</span></p>
        </div>
        <div class="weui-cell__bd select-year">
            <div id="trigger-select-year">{{$year_param}}</div>
        </div>
    </div>
    <div class="weui-flex" style="line-height: 40px;">
        <div class="weui-flex__item opinion-bk">
            <input class='op-name'  type="text" name="opinion-name" value="{{$feedback->name}}" data-values="{{$feedback->id}}"/><i style="margin-left: 10px;" class="icon iconfont icon-xiugai"  data-id="{{$feedback->id}}"  data-name="{{$feedback->name}}"></i>
            <i class="icon iconfont icon-xiala"></i>
        </div>
    </div>
    <form class="rewards-setting" onsubmit="return false;">
        <div class="rewards-list">
            <div class="weui-flex">
                <div class="weui-flex__item">
                    <p>等级名称</p>
                </div>
                <div class="weui-flex__item">
                    <p>对应分值</p>
                </div>
            </div>
            @foreach(unserialize($feedback->detail) as $k=>$v)
                <div class="weui-flex">
                    <div class="weui-flex__item">
                        <input type="text" class="" name="opname[]" value="{{$k}}">
                    </div>
                    <div class="weui-flex__item">
                        <input type="text" class="input-score" name="opvalue[]" value="{{$v}}" data-values="{{$v}}">
                    </div>
                </div>
            @endforeach
        </div>
        <input type="hidden" name="year" value="{{$year_param}}">
        {!! csrf_field() !!}
        <a href="javascript:;" class="btn-submit weui-btn weui-btn_color">完成</a>
    </form>
    <!-- 隐藏考核按钮部分-->
    @include('sysadmin.admin-caidan')
</div>
<div class="shadow-hidden"></div>
<div class="hidden-sec">
    <div class="popup"><h3>修改名称</h3><i class="weui-icon-cancel"></i></div>
    <p>输入名称</p>
    <input type="text" value="" name="pro-name" class="input text-input">
    <input type="hidden" value="" name="pro-id" class="input text-input">
    <a class="sub-mit modi-nickname" href="javascript:void(0);">保存</a>
</div>
<div class="fix-message">
    @if($skinid == 3)
        <img src="/img-theme-pink/que-3.png">
    @elseif($skinid == 1)
        <img src="/img-theme-pink/que-2.png">
    @elseif($skinid == 2)
        <img src="/img-theme-pink/que-1.png">
    @endif
</div>
<script src="{{asset('/kaohe/js/jquery-2.1.4.min.js')}}"></script>
<script src="{{asset('/addons/jquery-weui-build/js/fastclick.js')}}"></script>
<script src="/js/mobileSelect.js"></script>
<script>
    $(function() {
        document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
        FastClick.attach(document.body);
    });
</script>
<script src="{{asset('/addons/jquery-weui-build/js/jquery-weui.min.js')}}"></script>

<script>
    $(document).ready(function () {
        $('.fix-message img').click(function () {
            $.alert("月度意见设置的对应分值范围为0-5分；意见等级名称可自定义，可设置为一般（非常不满意）、尚可（不满意）、良好（中规中矩）、优秀（比较满意）、超人（特别好）等。", "提示");
        })
        $('.kaohe-item').click(function(){
            $('.show-hidden').toggle();
        });
        $('.admin-item').click(function(){
            $('.front-show-hidden').toggle();
        });

        var rearray = {!! $names !!};
        $(".op-name").select({
            title: "选择意见名称",
            items: rearray,
            onClose:function(){
                var fid = $('input[name=opinion-name]').attr('data-values');
                window.location.href='/sysadmin/feedback/feedback?feedid='+fid;
            }
        });


        $(".input-score").select({
            title: "选择分值",
            items: [{
                'title':'0',
                'value':'0',
            },{
                'title':'1',
                'value':'1',
            },{
                'title':'2',
                'value':'2',
            },{
                'title':'3',
                'value':'3',
            },{
                'title':'4',
                'value':'4',
            },{
                'title':'5',
                'value':'5',
            }],
            onClose: function(data) {
                $(".mian-container").css({"position":"initial","height":"auto"});
            },
            onOpen: function(data) {
                $(".mian-container").css({'position':'fixed',"width":"100%"});
            }
        });


        $('body').on('click','.icon-xiugai',function(){
            var that=this;
            var t_id = $(that).attr('data-id');
            var t_name = $(that).attr('data-name');
            $('input[name=pro-id]').val(t_id);
            $('input[name=pro-name]').val(t_name);
            $('.hidden-sec').css('display','block');
            $('.shadow-hidden').css('display','block');
        });

        $('.hidden-sec .popup i').click(function () {
            $('.hidden-sec').css('display','none');
            $('.shadow-hidden').css('display','none');
        });

        $('.sub-mit').click(function () {
            var name = $('input[name=pro-name]').val();
            var id = $('input[name=pro-id]').val();
            if(name.length>7){
                $.alert("项目名请在7字以内！");
            }else{
                var token = $('input[name=_token]').val();
                $.ajax({
                    'url': '/sysadmin/feedback/modify-feedback-name?_token='+token+'&feedid='+id + '&name=' + name,
                    'type': 'POST',
                    'data': '',
                    error: function (request) {
                        $.toast('网络错误',"text");
                    },
                    success: function (data) {
                        if (data.status == 'success') {
                            $.toast("操作成功");
                            window.location.reload();
                        } else {
                            $.toast(data.msg,"text");
                        }
                    },
                });

            }
        })

        //ajax表单提交
        $('.btn-submit').click(function(){
            var token = $('input[name=_token]').val();
            var feedid = $('input[name=opinion-name]').attr('data-values');
            var ids = [];
            $('input[name="opname[]"]').each(function () {
                if($(this).val().length > 7){
                    $.toast('名称太长',"text");
                    return false;
                }
                ids.push($(this).val());
            });
            var year = $('input[name=year]').val();
            var pids = [];
            $('input[name="opvalue[]"]').each(function () {
                pids.push($(this).attr('data-values'));
            });
            $.ajax({
                'url': '/sysadmin/feedback/modify-feedback?_token='+token+'&feedid='+feedid + '&year=' + year,
                'type': 'POST',
                'data': {'feed_name':JSON.stringify(ids),'feed_score':JSON.stringify(pids)},
                error: function (request) {
                    $.toast('网络错误',"text");
                },
                success: function (data) {
                    if (data.status == 'success') {
                        $.toast("操作成功");
                        window.location.href='/admin/set/company_edit';
                    } else {
                        $.toast(data.msg,"text");
                    }
                },
            });
        })
    })
</script>
<script>
    $(document).ready(function(){
        var UplinkData = {!! $yearlist !!};
        var mobileSelect3 = new MobileSelect({
            trigger: '#trigger-select-year',
            title: '选择时间',
            wheels: [
                {data: UplinkData}
            ],
            //     keyMap: {
            //        id:'id',
            //        value: 'name',
            //        childs :'son'
            //      },
            position: [0, 1],
            callback: function (indexArr, data) {
                //
                var year = data[0].id;

                window.location.href = '/sysadmin/feedback/feedback?year=' + year ;
                console.log(data[0].id); //返回选中的json数据
            }
        });
    });
</script>
</body>
</html>